package com.ruoyi.project.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.domain.TFillinganswer;
import com.ruoyi.project.system.service.ITFillinganswerService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 填空题答案Controller
 * 
 * @author ruoyi
 * @date 2020-05-09
 */
@RestController
@RequestMapping("/system/fillinganswer")
public class TFillinganswerController extends BaseController
{
    @Autowired
    private ITFillinganswerService tFillinganswerService;

    /**
     * 查询填空题答案列表
     */
    @PreAuthorize("@ss.hasPermi('system:fillinganswer:list')")
    @GetMapping("/list")
    public TableDataInfo list(TFillinganswer tFillinganswer)
    {
        startPage();
        System.out.println("tFillinganswer = " + tFillinganswer);
        List<TFillinganswer> list = tFillinganswerService.selectTFillinganswerList(tFillinganswer);
        return getDataTable(list);
    }

    /**
     * 导出填空题答案列表
     */
    @PreAuthorize("@ss.hasPermi('system:fillinganswer:export')")
    @Log(title = "填空题答案", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TFillinganswer tFillinganswer)
    {
        List<TFillinganswer> list = tFillinganswerService.selectTFillinganswerList(tFillinganswer);
        ExcelUtil<TFillinganswer> util = new ExcelUtil<TFillinganswer>(TFillinganswer.class);
        return util.exportExcel(list, "fillinganswer");
    }

    /**
     * 获取填空题答案详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:fillinganswer:query')")
    @GetMapping(value = "/{fillinganswerId}")
    public AjaxResult getInfo(@PathVariable("fillinganswerId") Integer fillinganswerId)
    {
        return AjaxResult.success(tFillinganswerService.selectTFillinganswerById(fillinganswerId));
    }

    /**
     * 新增填空题答案
     */
    @PreAuthorize("@ss.hasPermi('system:fillinganswer:add')")
    @Log(title = "填空题答案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TFillinganswer tFillinganswer)
    {

        return toAjax(tFillinganswerService.insertTFillinganswer(tFillinganswer));
    }

    /**
     * 修改填空题答案
     */
    @PreAuthorize("@ss.hasPermi('system:fillinganswer:edit')")
    @Log(title = "填空题答案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TFillinganswer tFillinganswer)
    {
        return toAjax(tFillinganswerService.updateTFillinganswer(tFillinganswer));
    }

    /**
     * 删除填空题答案
     */
    @PreAuthorize("@ss.hasPermi('system:fillinganswer:remove')")
    @Log(title = "填空题答案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fillinganswerIds}")
    public AjaxResult remove(@PathVariable Integer[] fillinganswerIds)
    {
        return toAjax(tFillinganswerService.deleteTFillinganswerByIds(fillinganswerIds));
    }
}
